package com.ruoyi.scsystem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scsystem.domain.SysDepartmentStat;
import com.ruoyi.scsystem.service.ISysDepartmentStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查询统计Controller
 * 
 * @author cai
 * @date 2022-09-19
 */
@RestController
@RequestMapping("/scsystem/deptstat")
public class SysDepartmentStatController extends BaseController
{
    @Autowired
    private ISysDepartmentStatService sysDepartmentStatService;

    /**
     * 查询查询统计列表
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDepartmentStat sysDepartmentStat)
    {
        startPage();
        List<SysDepartmentStat> list = sysDepartmentStatService.selectSysDepartmentStatList(sysDepartmentStat);
        return getDataTable(list);
    }

    /**
     * 导出查询统计列表
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:export')")
    @Log(title = "查询统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDepartmentStat sysDepartmentStat)
    {
        List<SysDepartmentStat> list = sysDepartmentStatService.selectSysDepartmentStatList(sysDepartmentStat);
        ExcelUtil<SysDepartmentStat> util = new ExcelUtil<SysDepartmentStat>(SysDepartmentStat.class);
        util.exportExcel(response, list, "查询统计数据");
    }

    /**
     * 获取查询统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(sysDepartmentStatService.selectSysDepartmentStatById(id));
    }

    /**
     * 新增查询统计
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:add')")
    @Log(title = "查询统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDepartmentStat sysDepartmentStat)
    {
        return toAjax(sysDepartmentStatService.insertSysDepartmentStat(sysDepartmentStat));
    }

    /**
     * 修改查询统计
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:edit')")
    @Log(title = "查询统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDepartmentStat sysDepartmentStat)
    {
        return toAjax(sysDepartmentStatService.updateSysDepartmentStat(sysDepartmentStat));
    }

    /**
     * 删除查询统计
     */
    @PreAuthorize("@ss.hasPermi('scsystem:deptstat:remove')")
    @Log(title = "查询统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysDepartmentStatService.deleteSysDepartmentStatByIds(ids));
    }
}
